home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 134_01 / ctoatbls.csm < prev    next >
Text File  |  1985-08-19  |  9KB  |  338 lines

  1. ;    CTOATBLS.CSM -- Constant tables for CTOA CRL-to-CSM postprocessor
  2.  
  3. ;    This file contains two functions, OPCTABL and CCCTABL.  They return
  4. ;    pointers to constant tables of opcodes and C.CCC entry points,
  5. ;    respectively.  They are created in assembly language because BDS C
  6. ;    won't do initializers, and boy do I wish Leor would do something
  7. ;    about that.
  8.  
  9.     MACLIB    "BDS.LIB"
  10.  
  11. ; OPCTABL
  12.  
  13. ;    struct opc_entry {
  14. ;        char mask;        /* Mask to AND with opcode */
  15. ;        char value;        /* Value to compare with opcode&mask */
  16. ;        char opcode [5];    /* Opcode name in ASCII */
  17. ;        char type;        /* Type of opcode (see below) */
  18. ;        } *opctabl ();
  19.  
  20. ;    Opcode types are as follows:
  21.  
  22. OP$SIMPLE      EQU    1    ; Simple 1-byte operation
  23. OP$LXI         EQU    2    ; LXI
  24. OP$RPSP        EQU    3    ; Register pair operation that can use SP
  25. OP$REG53       EQU    4    ; Register operation with reg # in bits 5-3
  26. OP$MVI         EQU    5    ; MVI
  27. OP$DATA1       EQU    6    ; LDA or STA; address in 1-byte data area
  28. OP$DATA2       EQU    7    ; LHLD or SHLD; address is 2-byte data area
  29. OP$MOV         EQU    8    ; MOV
  30. OP$ARITH       EQU    9    ; Arithmetic operation between A and register
  31. OP$CONRET      EQU    10    ; Conditional return
  32. OP$RPPSW       EQU    11    ; PUSH or POP
  33. OP$CONTRA      EQU    12    ; Conditional transfer
  34. OP$TRANS       EQU    13    ; Unconditional CALL or JMP
  35. OP$IARITH      EQU    14    ; Immediate arithmetic
  36. OP$RST         EQU    15    ; Restart other than 6
  37. OP$IO          EQU    16    ; IN or OUT
  38. OP$RST6        EQU    17    ; Restart 6
  39. OP$WHAT        EQU    18    ; Unknown operation
  40.  
  41.     FUNCTION    OPCTABL
  42.  
  43.     lxi    h, optbl
  44.     ret
  45.  
  46. optbl:
  47.  
  48. ;    First, the opcodes that don't fit neat patterns
  49.  
  50.     db    0FFh, 022h, 'shld', 0h, OP$DATA2
  51.     db    0FFh, 02Ah, 'lhld', 0h, OP$DATA2
  52.     db    0FFh, 032h, 'sta', 0h, 0h, OP$DATA1
  53.     db    0FFh, 03Ah, 'lda', 0h, 0h, OP$DATA1
  54.     db    0FFh, 076h, 'hlt', 0h, 0h, OP$SIMPLE
  55.     db    0FFh, 0F7h, 0h, 0h, 0h, 0h, 0h, OP$RST6
  56.  
  57. ;    The rest of the opcodes, in numerical order
  58.  
  59.     db    0FFh, 000h, 'nop', 0h, 0h, OP$SIMPLE
  60.     db    0CFh, 001h, 'lxi', 0h, 0h, OP$LXI
  61.     db    0CFh, 002h, 'stax', 0h, OP$RPSP
  62.     db    0CFh, 003h, 'inx', 0h, 0h, OP$RPSP
  63.     db    0C7h, 004h, 'inr', 0h, 0h, OP$REG53
  64.     db    0C7h, 005h, 'dcr', 0h, 0h, OP$REG53
  65.     db    0C7h, 006h, 'mvi', 0h, 0h, OP$MVI
  66.     db    0FFh, 007h, 'rlc', 0h, 0h, OP$SIMPLE
  67.     db    0CFh, 009h, 'dad', 0h, 0h, OP$RPSP
  68.     db    0CFh, 00Ah, 'ldax', 0h, OP$RPSP
  69.     db    0CFh, 00Bh, 'dcx', 0h, 0h, OP$RPSP
  70.     db    0FFh, 00Fh, 'rrc', 0h, 0h, OP$SIMPLE
  71.     db    0FFh, 017h, 'ral', 0h, 0h, OP$SIMPLE
  72.     db    0FFh, 01Fh, 'rar', 0h, 0h, OP$SIMPLE
  73.     db    0FFh, 027h, 'daa', 0h, 0h, OP$SIMPLE
  74.     db    0FFh, 02Fh, 'cma', 0h, 0h, OP$SIMPLE
  75.     db    0FFh, 037h, 'stc', 0h, 0h, OP$SIMPLE
  76.     db    0FFh, 03Fh, 'cmc', 0h, 0h, OP$SIMPLE
  77.     db    0C0h, 040h, 'mov', 0h, 0h, OP$MOV
  78.     db    0F8h, 080h, 'add', 0h, 0h, OP$ARITH
  79.     db    0F8h, 088h, 'adc', 0h, 0h, OP$ARITH
  80.     db    0F8h, 090h, 'sub', 0h, 0h, OP$ARITH
  81.     db    0F8h, 098h, 'sbb', 0h, 0h, OP$ARITH
  82.     db    0F8h, 0A0h, 'ana', 0h, 0h, OP$ARITH
  83.     db    0F8h, 0A8h, 'xra', 0h, 0h, OP$ARITH
  84.     db    0F8h, 0B0h, 'ora', 0h, 0h, OP$ARITH
  85.     db    0F8h, 0B8h, 'cmp', 0h, 0h, OP$ARITH
  86.     db    0C7h, 0C0h, 'r', 0h, 0h, 0h, 0h, OP$CONRET
  87.     db    0CFh, 0C1h, 'pop', 0h, 0h, OP$RPPSW
  88.     db    0C7h, 0C2h, 'j', 0h, 0h, 0h, 0h, OP$CONTRA
  89.     db    0FFh, 0C3h, 'jmp', 0h, 0h, OP$TRANS
  90.     db    0C7h, 0C4h, 'c', 0h, 0h, 0h, 0h, OP$CONTRA
  91.     db    0CFh, 0C5h, 'push', 0h, OP$RPPSW
  92.     db    0FFh, 0C6h, 'adi', 0h, 0h, OP$IARITH
  93.     db    0C7h, 0C7h, 'rst', 0h, 0h, OP$RST
  94.     db    0FFh, 0C9h, 'ret', 0h, 0h, OP$SIMPLE
  95.     db    0FFh, 0CDh, 'call', 0h, OP$TRANS
  96.     db    0FFh, 0CEh, 'aci', 0h, 0h, OP$IARITH
  97.     db    0FFh, 0D3h, 'out', 0h, 0h, OP$IO
  98.     db    0FFh, 0D6h, 'sui', 0h, 0h, OP$IARITH
  99.     db    0FFh, 0DBh, 'in', 0h, 0h, 0h, OP$IO
  100.     db    0FFh, 0DEh, 'sbi', 0h, 0h, OP$IARITH
  101.     db    0FFh, 0E3h, 'xthl', 0h, OP$SIMPLE
  102.     db    0FFh, 0E6h, 'ani', 0h, 0h, OP$IARITH
  103.     db    0FFh, 0E9h, 'pchl', 0h, OP$SIMPLE
  104.     db    0FFh, 0EBh, 'xchg', 0h, OP$SIMPLE
  105.     db    0FFh, 0EEh, 'xri', 0h, 0h, OP$IARITH
  106.     db    0FFh, 0F3h, 'di', 0h, 0h, 0h, OP$SIMPLE
  107.     db    0FFh, 0F6h, 'ori', 0h, 0h, OP$IARITH
  108.     db    0FFh, 0F9h, 'sphl', 0h, OP$SIMPLE
  109.     db    0FFh, 0FBh, 'ei', 0h, 0h, 0h, OP$SIMPLE
  110.     db    0FFh, 0FEh, 'cpi', 0h, 0h, OP$IARITH
  111.     db    000h, 000h, 'db', 0h, 0h, 0h, OP$WHAT
  112.  
  113.     ENDFUNC    OPCTABL
  114.  
  115. ; CCCTABL
  116.  
  117. ;    The following function defines the locations in C.CCC accessed directly
  118. ;    by code external to the run-time package.
  119.  
  120. ;    struct cccentry {
  121. ;        unsigned address;    /* Address of the word in C.CCC */
  122. ;        char flags;        /* Flags (see below) */
  123. ;        char name [7];        /* Name of the entry point */
  124. ;        } *ccctabl ();
  125.  
  126. ;    The flags are as follows:
  127.  
  128. CODE    EQU    080h        ; Entry is a procedure address
  129. DATA    EQU    040h        ; Entry is a data address
  130. NMACLIB    EQU    020h        ; Entry does not appear in BDS.LIB
  131.  
  132. LOCAL    EQU    004h        ; Offset that follows is a local address
  133. ;    Bits 1-0 are the number of bytes in an offset, if any, following
  134. ;    a CALL to the entry point.
  135.  
  136.     FUNCTION    CCCTABL
  137.  
  138.     lxi    h,cccdefs
  139.     ret
  140.  
  141. cccdefs:            ; Definitions for BDS C 1.50
  142.  
  143. ;    Constant locations at head of C.CCC
  144.  
  145.     dw    fexitv
  146.     db    CODE, 'fexitv', 0h
  147.     dw    extrns
  148.     db    DATA, 'extrns', 0h
  149.     dw    cccsiz
  150.     db    DATA, 'cccsiz', 0h
  151.     dw    codend
  152.     db    DATA, 'codend', 0h
  153.     dw    freram
  154.     db    DATA, 'freram', 0h
  155.  
  156. ;    C.CCC entry points
  157.  
  158.     dw    error
  159.     db    CODE, 'error', 0h, 0h
  160.     dw    setfcb
  161.     db    CODE, 'setfcb', 0h
  162.     dw    fgfd
  163.     db    CODE, 'fgfd', 0h, 0h, 0h
  164.     dw    fgfcb
  165.     db    CODE, 'fgfcb', 0h, 0h
  166.     dw    setfcu
  167.     db    CODE, 'setfcu', 0h
  168.     dw    setusr
  169.     db    CODE, 'setusr', 0h
  170.     dw    rstusr
  171.     db    CODE, 'rstusr', 0h
  172.     dw    khack
  173.     db    CODE, 'khack', 0h, 0h
  174.     dw    clrex
  175.     db    CODE, 'clrex', 0h, 0h
  176.     dw    eqwel
  177.     db    CODE, 'eqwel', 0h, 0h
  178.     dw    smod
  179.     db    CODE, 'smod', 0h, 0h, 0h
  180.     dw    usmod
  181.     db    CODE, 'usmod', 0h, 0h
  182.     dw    smul
  183.     db    CODE, 'smul', 0h, 0h, 0h
  184.     dw    usmul
  185.     db    CODE, 'usmul', 0h, 0h
  186.     dw    usdiv
  187.     db    CODE, 'usdiv', 0h, 0h
  188.     dw    sdiv
  189.     db    CODE, 'sdiv', 0h, 0h, 0h
  190.     dw    cmphd
  191.     db    CODE, 'cmphd', 0h, 0h
  192.     dw    cmh
  193.     db    CODE, 'cmh', 0h, 0h, 0h, 0h
  194.     dw    cmd
  195.     db    CODE, 'cmd', 0h, 0h, 0h, 0h
  196.     dw    ma1toh
  197.     db    CODE, 'ma1toh', 0h
  198.     dw    ma2toh
  199.     db    CODE, 'ma2toh', 0h
  200.     dw    ma3toh
  201.     db    CODE, 'ma3toh', 0h
  202.     dw    ma4toh
  203.     db    CODE, 'ma4toh', 0h
  204.     dw    ma5toh
  205.     db    CODE, 'ma5toh', 0h
  206.     dw    ma6toh
  207.     db    CODE, 'ma6toh', 0h
  208.     dw    ma7toh
  209.     db    CODE, 'ma7toh', 0h
  210.     dw    arghak
  211.     db    CODE, 'arghak', 0h
  212.  
  213. ;    C.CCC RAM addresses
  214.  
  215.     dw    errnum
  216.     db    DATA, 'errnum', 0h
  217.     dw    pbase
  218.     db    DATA, 'pbase', 0h, 0h
  219.     dw    ysize
  220.     db    DATA, 'ysize', 0h, 0h
  221.     dw    xsize
  222.     db    DATA, 'xsize', 0h, 0h
  223.     dw    psize
  224.     db    DATA, 'psize', 0h, 0h
  225.     dw    rseed
  226.     db    DATA, 'rseed', 0h, 0h
  227.     dw    args
  228.     db    DATA, 'args', 0h, 0h, 0h
  229.     dw    iohack
  230.     db    DATA, 'iohack', 0h
  231.     dw    allocp
  232.     db    DATA, 'allocp', 0h
  233.     dw    alocmx
  234.     db    DATA, 'alocmx', 0h
  235.     dw    tmp
  236.     db    DATA, 'tmp', 0h, 0h, 0h, 0h
  237.     dw    tmp1
  238.     db    DATA, 'tmp1', 0h, 0h, 0h
  239.     dw    tmp2
  240.     db    DATA, 'tmp2', 0h, 0h, 0h
  241.     dw    tmp2a
  242.     db    DATA, 'tmp2a', 0h, 0h
  243.     dw    ungetl
  244.     db    DATA, 'ungetl', 0h
  245.     dw    unused
  246.     db    DATA, 'unused', 0h
  247.     dw    curusr
  248.     db    DATA, 'curusr', 0h
  249.     dw    usrnum
  250.     db    DATA, 'usrnum', 0h
  251.     dw    mode
  252.     db    DATA, 'mode', 0h, 0h, 0h
  253.     dw    freeze
  254.     db    DATA, 'freeze', 0h
  255.     dw    pending            ; Special case 'cuz name too long
  256.     db    DATA+NMACLIB, 'pendin', 0h
  257.     dw    pendch
  258.     db    DATA, 'pendch', 0h
  259.     dw    quitc
  260.     db    DATA, 'quitc', 0h, 0h
  261.  
  262. ;    Compiler-accessed operators not in BDS.LIB:
  263.  
  264.     dw    014Dh
  265.     db    CODE+NMACLIB+2, 'ldei', 0h, 0h, 0h
  266.     dw    015Ch
  267.     db    CODE+NMACLIB+1, 'sdei', 0h, 0h, 0h
  268.     dw    016Bh
  269.     db    CODE+NMACLIB+2, 'lsei', 0h, 0h, 0h
  270.     dw    0177h
  271.     db    CODE+NMACLIB+1, 'ssei', 0h, 0h, 0h
  272.     dw    0183h
  273.     db    CODE+NMACLIB+LOCAL+2, 'ldli', 0h, 0h, 0h
  274.     dw    0190h
  275.     db    CODE+NMACLIB+LOCAL+1, 'sdli', 0h, 0h, 0h
  276.     dw    019Dh
  277.     db    CODE+NMACLIB, 'pzinh', 0h, 0h
  278.     dw    01A3h
  279.     db    CODE+NMACLIB, 'pnzinh', 0h
  280.     dw    01A9h
  281.     db    CODE+NMACLIB, 'pcinh', 0h, 0h
  282.     dw    01AFh
  283.     db    CODE+NMACLIB, 'pncinh', 0h
  284.     dw    01B5h
  285.     db    CODE+NMACLIB, 'ppinh', 0h, 0h
  286.     dw    01BBh
  287.     db    CODE+NMACLIB, 'pminh', 0h, 0h
  288.     dw    01C1h
  289.     db    CODE+NMACLIB, 'pzind', 0h, 0h
  290.     dw    01C7h
  291.     db    CODE+NMACLIB, 'pnzind', 0h
  292.     dw    01CDh
  293.     db    CODE+NMACLIB, 'pcind', 0h, 0h
  294.     dw    01D3h
  295.     db    CODE+NMACLIB, 'pncind', 0h
  296.     dw    01D9h
  297.     db    CODE+NMACLIB, 'ppind', 0h, 0h
  298.     dw    01DFh
  299.     db    CODE+NMACLIB, 'pmind', 0h, 0h
  300.     dw    01EBh
  301.     db    CODE+NMACLIB, 'blau', 0h, 0h, 0h
  302.     dw    01ECh
  303.     db    CODE+NMACLIB, 'albu', 0h, 0h, 0h
  304.     dw    01F2h
  305.     db    CODE+NMACLIB, 'bgau', 0h, 0h, 0h
  306.     dw    01F3h
  307.     db    CODE+NMACLIB, 'agbu', 0h, 0h, 0h
  308.     dw    01F9h
  309.     db    CODE+NMACLIB, 'blas', 0h, 0h, 0h
  310.     dw    01FAh
  311.     db